package com.bwie.Timer;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bwie.mapper.TbGiftMapper;
import com.bwie.pojo.TbDict;
import com.bwie.pojo.TbGift;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.List;

/**
 * @Author: zhaijiaqi
 * @Date: 2025/7/15 17:27
 * @Description:
 **/
@Component
@Slf4j
public class updateStatus {

    @Autowired
    TbGiftMapper tbGiftMapper;

  //  @Scheduled(cron = "0 0/1 * * * ?")
    public void getUpdate(){
        log.info("开始执行定时任务");
        QueryWrapper<TbGift> wrapper = new QueryWrapper<>();
      wrapper.lambda().le(TbGift::getEndTime,new Date());
        List<TbGift> tbGifts = tbGiftMapper.selectList(wrapper);
        for (TbGift tbGift : tbGifts) {
            tbGift.setGiftStatus(3);
            tbGiftMapper.updateById(tbGift);
        }
        log.info("执行结束定时任务");
    }
}
